import axios from "axios";

class AskService {
  constructor(baseUrl, timeout = 5000) {
    this.axios = axios.create({
      baseURL: baseUrl,
      timeout: timeout
    })
  }

  request(config) {
    return new Promise((resolve, reject) => {
      return this.axios(config).then(res => {
        resolve(res.data)
      }).catch(err => {
        reject(err)
      })
    })
  }

  get(config) {
    return this.request({
      ...config,
      mothod: 'get',
    })
  }

  post(config) {
    return this.request({
      ...config,
      mothod: 'post',
    })
  }
}

export default new AskService('http://123.207.32.32:9001')